package com.xcf.controller.business.common;

import java.io.PrintWriter;
import java.util.List;

import javax.annotation.Resource;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;


import com.xcf.controller.base.BaseController;
import com.xcf.service.business.common.transportclause.TransportClauseService;
import com.xcf.util.PageData;
@Controller
@RequestMapping(value="/transportClause")
public class TransportClauseController extends BaseController{
	String menuUrl = "transportClause/list";
@Resource
private TransportClauseService transport;
/**
 * 列表查询
 * @return
 * @throws Exception
 */
@RequestMapping(value="/list")
public ModelAndView TransportClauseList() throws Exception{
	ModelAndView view = new ModelAndView();
	PageData pd = new PageData();
	pd = this.getPageData();
	List<PageData> transportInfo = transport.findTransportClauseInfo(pd);	

	
	view.addObject("transport",transportInfo);
	view.setViewName("/business/common/transportclause/transport_clause_list");
	
	return view;
	
}

/**
 * 保存或修改数据
 * @return
 * @throws Exception
 */
@RequestMapping(value="/addTransportClauseInfo")
@ResponseBody
public String addTransportClauseInfo()throws Exception{
	PageData pd = new PageData();
	pd = this.getPageData();
	//如果id为空则保存，id不为空则修改
	if(pd.getString("ID")==null || pd.getString("ID")==""){
//	pd.put("ID",this.get32UUID());
		//运输条款（由起始条款和终止条款拼接）
		pd.put("TRANSPORT_CLAUSE", pd.getString("START_CLAUSE")+"--"+pd.getString("END_CLAUSE"));
	transport.addTransportClauseInfo(pd);
	}else{
		//运输条款（由起始条款和终止条款拼接）
		pd.put("TRANSPORT_CLAUSE", pd.getString("START_CLAUSE")+"--"+pd.getString("END_CLAUSE"));
	transport.updateTransportClause(pd);
	}
	return null;
	
}
/**
 * 更新运输条款信息跳转编辑页面
 * @return
 * @throws Exception 
 */
@RequestMapping(value="/updateTransportClauseInfo")
public ModelAndView updateTransportClauseInfo() throws Exception{
	PageData pd = new PageData();
	pd = this.getPageData();
	ModelAndView view = new ModelAndView();
	pd = transport.findTransportClauseInfoById(pd);
	view.addObject("pd",pd);
	view.addObject("transport",pd);
	view.addObject("msg", "addTransportClauseInfo");
	view.setViewName("/business/common/transportclause/transport_clause_edit");
	return view;
	
}
/**
 * 删除运输条款信息
 * @return
 * @throws Exception
 */
@RequestMapping(value="/deleteTransportClauseInfo")
@ResponseBody
public String deleteTransportClauseInfo() throws Exception{
	PageData pd = new PageData();
	pd = this.getPageData();
	transport.deleteTransportClause(pd);
	return null;
}
}
